local hx__mingji = fk.CreateSkill{
  name = "hx__mingji",
  tags = { Skill.Compulsory },
}

local HX = require "packages/huixiangkill/hxfs"
local U = require "packages/utility/utility"

hx__mingji:addEffect(fk.CardUsing, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    local skills = table.filter(player:getSkillNameList(), function(skill_name)
      local skill = Fk.skills[skill_name]
      return skill:hasTag(Skill.Switch)
    end)
    return target == player and player:hasSkill(hx__mingji.name) and data.card.type == Card.TypeTrick and #skills > 0
    end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player, "@hx__mingji-turn", 1)
    local skills = table.filter(player:getSkillNameList(), function(skill_name)
      local skill = Fk.skills[skill_name]
      return skill:hasTag(Skill.Switch)
    end)
    if #skills > 0 then
      local choice = room:askToChoice(player,{
        choices = skills,
        skill_name = hx__mingji.name,
        cancelable = false,
        prompt = "#hx__mingji",
        detailed = true,
      })
      if choice then
        U.SetSwitchSkillState(player, choice)
        HX.SetTheSkillTimes(room, player, choice, 0)
      end
      if choice == "hx__ziruo" then
        room:unbanSortingHandcards(player, "-_hx__ziruo-turn")
      end
    end
  end,
})

hx__mingji:addEffect("maxcards", {
  correct_func = function(self, player)
    return player:hasSkill(hx__mingji.name) and player:getMark("@hx__mingji-turn")
  end
})

return hx__mingji
